﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
 lang="en" dir="ltr">
<head>
  <title>Title Formatting Syntax Reference</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <link rel="stylesheet" type="text/css" href="titleformat_help.css" />
</head>
<body>
<div class="dokuwiki export">
<div class="toc">
<div class="tocheader toctoggle" id="toc__header">Table of Contents</div>
<div id="toc__inside">

<ul class="toc">
<li class="clear">

<ul class="toc">
<li class="level2"><div class="li"><span class="li"><a href="#title_formatting_syntax_reference" class="toc">Title Formatting Syntax Reference</a></span></div>
<ul class="toc">
<li class="level3"><div class="li"><span class="li"><a href="#generic_fields" class="toc">Generic fields</a></span></div></li>
<li class="level3"><div class="li"><span class="li"><a href="#context-specific_fields" class="toc">Context-specific fields</a></span></div></li>
<li class="level3"><div class="li"><span class="li"><a href="#functions" class="toc">Functions</a></span></div></li>
<li class="level3"><div class="li"><span class="li"><a href="#variable_operations" class="toc">Variable operations</a></span></div></li>
<li class="level3"><div class="li"><span class="li"><a href="#other" class="toc">Other</a></span></div></li></ul>
</li></ul>
</li></ul>
</div>
</div>



<h2><a name="title_formatting_syntax_reference" id="title_formatting_syntax_reference">Title Formatting Syntax Reference</a></h2>
<div class="level2">

</div>
<!-- SECTION "Title Formatting Syntax Reference" [1-46] -->
<h3><a name="generic_fields" id="generic_fields">Generic fields</a></h3>
<div class="level3">
<table class="inline">
	<tr>
		<th> Syntax </th><th> Description </th>
	</tr>
	<tr>
		<td> %title% </td><td> Title of the track. If “title” metadata field is missing, file name is used instead. </td>
	</tr>
	<tr>
		<td> %artist% </td><td> Name of the artist of the track. Checks following metadata fields, in this order: “artist”, “album artist”, “composer”, “performer”. </td>
	</tr>
	<tr>
		<td> %album artist% </td><td> Name of the artist of the album specified track belongs to. Checks following metadata fields, in this order: “album artist”, “artist”, “composer”, “performer”. The difference between this and %artist% is that %album artist% is intended for use where consistent value across entire album is needed even when per-track artists values vary. </td>
	</tr>
	<tr>
		<td> %track artist% </td><td> Name of the artist of the track; present only if %album artist% is different than %artist% for specific track. Intended for use together with %album artist%, to indicate track-specific artist info, e.g. ”%album artist% - %title%[ &#039;//&#039; %track artist%]” - in this case, last part will be displayed only when track-specific artist info is present. </td>
	</tr>
	<tr>
		<td> %album% </td><td> Name of the album specified track belongs to. Checks following metadata fields, in this order: “album”, “venue”. </td>
	</tr>
	<tr>
		<td> %date% </td><td> Recording date (year) of the album specified track belongs to, using “date” metadata field. </td>
	</tr>
	<tr>
		<td> %genre% </td><td> Genre of the album specified track belongs to, using “genre” metadata field. </td>
	</tr>
	<tr>
		<td> %tracknumber% </td><td> Two-digit index of specified track within the album. Available only when “tracknumber” field is present in track’s metadata. </td>
	</tr>
	<tr>
		<td> %totaltracks% </td><td> Two-digit number of tracks within the album specified track belongs to. Available only when “totaltracks” field is present in track’s metadata. </td>
	</tr>
	<tr>
		<td> %discnumber% </td><td> Index of disc specified track belongs to, within the album. Available only when “discnumber”/“disc” field is present in track’s metadata. </td>
	</tr>
	<tr>
		<td> %totaldiscs% </td><td> Number of discs within the album specified track belongs to. Available only when “totaldiscs” field is present in track’s metadata. </td>
	</tr>
	<tr>
		<td> %codec% </td><td> Name of codec used to encode the track. If exact codec name is not available, file extension is used. </td>
	</tr>
	<tr>
		<td> %codec_profile% </td><td> Additional information about encoding settings used. Not always available. </td>
	</tr>
	<tr>
		<td> %filename% </td><td> Name of file, excluding directory path and extension. </td>
	</tr>
	<tr>
		<td> %filename_ext% </td><td> Name of the file, including extension but excluding directory path. </td>
	</tr>
	<tr>
		<td> %directoryname% </td><td> Name of the directory the file is in. </td>
	</tr>
	<tr>
		<td> %path% </td><td> Full path of the file. Note that %path_sort% should be use for sorting instead of %path%. </td>
	</tr>
	<tr>
		<td> %subsong% </td><td> Index of the track within the file, for use with file formats that support multiple tracks within single physical file (e.g. chapters or a cuesheet). </td>
	</tr>
	<tr>
		<td> %path_sort% </td><td colspan="2"> Path of the file; for use with sorting, where order of subsongs within a file needs to be preserved; exact value returned by it is undefined and should not be relied on. </td>
	</tr>
	<tr>
		<td> %length% </td><td> Length of the track, formatted as <em>[HH:]MM:SS</em>. </td>
	</tr>
	<tr>
		<td> %length_seconds% </td><td> Length of the track, in seconds, formatted as an integer. </td>
	</tr>
	<tr>
		<td> %bitrate% </td><td> Bitrate of the track in kilobits per second (kbps); includes dynamic VBR bitrate display for currently played track. </td>
	</tr>
	<tr>
		<td> %channels% </td><td> Number of channels in the track (mono/stereo/etc). </td>
	</tr>
	<tr>
		<td> %samplerate% </td><td> Sample rate of the track, in Hz. </td>
	</tr>
	<tr>
		<td> %replaygain_track_gain%, %replaygain_album_gain%, %replaygain_track_peak%, %replaygain_album_peak%, %replaygain_track_peak_db%, %replaygain_album_peak_db% </td><td> ReplayGain information. </td>
	</tr>
	<tr>
		<td> %filesize% </td><td> Size of the file, in bytes. </td>
	</tr>
	<tr>
		<td> %filesize_natural% </td><td> Size of the file, automatically formatted in appropriate units such as megabytes or kilobytes. </td>
	</tr>
	<tr>
		<td> %last_modified% </td><td> Last modification time of the file, formatted as <em>YYYY-MM-DD HH:MM:SS</em>. </td>
	</tr>
</table>

<p>
The above list is not complete, there are other less relevant fields as well as generic %field% &rArr; metadata and %__field% &rArr; tech info remappings provided for backwards compatibility. 
</p>

</div>
<!-- SECTION "Generic fields" [47-3887] -->
<h3><a name="context-specific_fields" id="context-specific_fields">Context-specific fields</a></h3>
<div class="level3">
<table class="inline">
	<tr>
		<th> Syntax </th><th> Description </th>
	</tr>
	<tr>
		<td> %list_index% </td><td> Index of the item on the list it belongs to. Applies to: playlist, list of items processed by masstagger/massrenamer, etc. Padded with zeros to match max. width of possible index within the list. </td>
	</tr>
	<tr>
		<td> %list_total% </td><td> Number of items on the list specified item belongs to. Applies to: playlist, list of items processed by masstagger/massrenamer, etc. </td>
	</tr>
	<tr>
		<td> %isplaying% </td><td> Present if e.g. a playlist item is currently being played, absent otherwise. Meant to be used as a switch for $if(). </td>
	</tr>
	<tr>
		<td> %ispaused% </td><td> Present if e.g. a playlist item is currently being played and is paused, absent otherwise. Meant to be used as a switch for $if(). </td>
	</tr>
	<tr>
		<td> %playback_time% </td><td> Current playback time, formatted as <em>[HH:]MM:SS</em>. Available only in contexts where playback related data is displayed, such as statusbar. </td>
	</tr>
	<tr>
		<td> %playback_time_seconds% </td><td> Current playback time, in seconds, formatted as integer. Available only in contexts where playback related data is displayed, such as statusbar. </td>
	</tr>
	<tr>
		<td> %playback_time_remaining% </td><td> Remaining playback time, formatted as <em>[HH:]MM:SS</em>. Available only in contexts where playback related data is displayed, such as statusbar. Not available when duration of currently playing track is not known. </td>
	</tr>
	<tr>
		<td> %playback_time_remaining_seconds% </td><td> Remaining playback time, in seconds, formatted as integer. Available only in contexts where playback related data is displayed, such as statusbar. Not available when length of currently playing track is not known. </td>
	</tr>
	<tr>
		<td> %queue_index% </td><td> Index of the specified item in the playback queue; available in playlist only. If the item has been queued multiple times, %queue_index% evaluates to the first index. </td>
	</tr>
	<tr>
		<td> %queue_indexes% </td><td> List of indexes of the specified item in the playback queue; available in playlist only. Same as %queue_index% unless the item has been queued more than once. </td>
	</tr>
	<tr>
		<td> %queue_total% </td><td> Total amount of tracks in playback queue. Available only for queued tracks, for technical reasons. </td>
	</tr>
</table>

</div>
<!-- SECTION "Context-specific fields" [3888-5918] -->
<h3><a name="functions" id="functions">Functions</a></h3>
<div class="level3">
<table class="inline">
	<tr>
		<th> Syntax </th><th> Description </th><th> Example </th>
	</tr>
	<tr>
		<td> $abbr(X) </td><td> Returns an abbreviation of X. </td><td> $abbr(%album%) </td>
	</tr>
	<tr>
		<td> $abbr(X,Y) </td><td> Returns an abbreviation of X if X is longer than Y characters; otherwise returns full value of X. </td><td> $abbr(%album%,5) </td>
	</tr>
	<tr>
		<td> $ansi(X) </td><td> Returns X with all characters not present in current system codepage replaced with closest matches. Useful for sanitizing filenames when interacting with other software that can&#039;t handle Unicode. </td><td> $ansi(%title%), $ansi(%filename%) </td>
	</tr>
	<tr>
		<td> $ascii(X) </td><td> Returns X with all non-<acronym title="American Standard Code for Information Interchange">ASCII</acronym> characters replaced with closest <acronym title="American Standard Code for Information Interchange">ASCII</acronym> matches. Useful for sanitizing filenames when interacting with other software that can&#039;t handle Unicode. </td><td> $ascii(%title%), $ascii(%filename%) </td>
	</tr>
	<tr>
		<td> $lower(X), $upper(X) </td><td> Converts X to lower/uppercase. </td><td> $upper(%title%) </td>
	</tr>
	<tr>
		<td> $num(X,Y) </td><td> Displays X as a number and pads with zeros up to Y characters (useful for track numbers etc). </td><td> $num(%tracknumber%,3) </td>
	</tr>
	<tr>
		<td> $caps(X) </td><td> Converts first letter in every word of X to uppercase, and all other letters to lowercase, e.g. “blah BLAH” &rArr; “Blah Blah”. </td><td> $caps(%title%) </td>
	</tr>
	<tr>
		<td> $caps2(X) </td><td> Similar to $caps, but leaves uppercase letters as they are, e.g. “blah BLAH” &rArr; “Blah BLAH”. </td><td> $caps2(%title%) </td>
	</tr>
	<tr>
		<td> $if(X,Y,Z) </td><td> If X contains at least one present field, executes/displays Y, otherwise executes/displays Z. </td><td> $if(%artist%,%artist%,unknown artist) </td>
	</tr>
	<tr>
		<td> $if2(X,Y) </td><td> Same as $if(X,X,Y). </td><td> </td>
	</tr>
	<tr>
		<td> $if3(X,Y,Z,..) </td><td> Returns the first of parameters that contains at least one present field. </td><td> </td>
	</tr>
	<tr>
		<td> $ifgreater(A,B,C,D) </td><td> If the number A is greater than the number B, executes/returns C, otherwise executes/returns D. </td><td> </td>
	</tr>
	<tr>
		<td> $iflonger(A,B,C,D) </td><td> If the string A is longer than B characters, executes/returns C, otherwise executes/returns D. </td><td> </td>
	</tr>
	<tr>
		<td> $ifequal(A,B,C,D) </td><td> If the number A is equal to the number B, executes/returns C, otherwise executes/returns D. </td><td> </td>
	</tr>
	<tr>
		<td> $longest(A,B,C,&hellip;.) </td><td> Compares lengths of of A,B,C&hellip; and returns the longest one. </td><td> $longest(%title%,%filename%) </td>
	</tr>
	<tr>
		<td> $len(X) </td><td> Returns length of the string X in characters. </td><td> </td>
	</tr>
	<tr>
		<td> $pad(X,Y), $pad_right(X,Y) </td><td> Pads X with spaces up to Y characters. </td><td> </td>
	</tr>
	<tr>
		<td> $pad(X,Y,Z), $pad_right(X,Y,Z) </td><td> Pads X with Z character up to Y characters. </td><td> </td>
	</tr>
	<tr>
		<td> $cut(X,Y) </td><td> Truncates X to Y characters. </td><td> </td>
	</tr>
	<tr>
		<td> $padcut(X,Y), $padcut_right(X,Y) </td><td> Pads X to Y characters and truncates to Y if longer. </td><td> </td>
	</tr>
	<tr>
		<td> $insert(A,B,N) </td><td> Inserts string B into string A after N characters. </td><td> </td>
	</tr>
	<tr>
		<td> $add(X,Y), $sub(X,Y), $mul(X,Y), $div(X,Y), $mod(X,Y), $min(X,Y), $max(X,Y) </td><td> Various math operations. </td><td> </td>
	</tr>
	<tr>
		<td> $left(X,Y) </td><td> Returns Y first characters of string X. </td><td> </td>
	</tr>
	<tr>
		<td> $right(X,Y) </td><td> Returns Y last characters of string X. </td><td> </td>
	</tr>
	<tr>
		<td> $and(X,Y), $or(X,Y), $xor(X,Y), $not(X) </td><td> Various logical operations, for use with $if(). </td><td> </td>
	</tr>
	<tr>
		<td> $fix_eol(x), $fix_eol(x,y) </td><td> Truncates multiline strings, adding ” (&hellip;)” (version 1) or y (version 2) at the end. </td><td> </td>
	</tr>
	<tr>
		<td> $meta(X) </td><td> Returns value of metadata field named X. </td><td> $meta(artist) </td>
	</tr>
	<tr>
		<td> $meta_sep(X,Y), $meta_sep(X,Y,Z) </td><td> Returns metadata field named X, with custom separators for multiple values </td><td> $meta(artist,&#039;, &#039;,&#039; and &#039;) &rArr; “artist1, artist2 and artist3” </td>
	</tr>
	<tr>
		<td> $meta_num(X) </td><td> Returns number of present values for metadata field X. </td>
	</tr>
	<tr>
		<td> $info(X) </td><td> Returns tech info field named X. </td><td> $info(bitrate) </td>
	</tr>
	<tr>
		<td> $char(X) </td><td> Inserts Unicode character no. X. </td><td> $char(9674) </td>
	</tr>
	<tr>
		<td> $strcmp(X,Y) </td><td> Returns “1” when strings X and Y are identical, empty string otherwise; intended for use with $if(). </td><td> </td>
	</tr>
	<tr>
		<td> $stricmp(X,Y) </td><td> Non-case-sensitive version of $strcmp(X,Y). </td><td> </td>
	</tr>
	<tr>
		<td> $directory(X), $directory(X,N) </td><td> Extracts directory name from the file path X, optionally goes up by N directory levels. </td><td> $directory(%path%,2) </td>
	</tr>
	<tr>
		<td> $directory_path(X) </td><td> Extracts directory path from the file path X. </td><td> $directory_path(%path%) </td>
	</tr>
	<tr>
		<td> $greater(X,Y) </td><td> Compares two integers, tests if X&gt;Y, intended for use with $if() and logical operators. </td><td> </td>
	</tr>
	<tr>
		<td> $longer(X,Y) </td><td> Compares two strings, tests if X is longer than Y, intended for use with $if() and logical operators. </td><td> </td>
	</tr>
	<tr>
		<td> $strchr(X,Y) </td><td> Finds first occurrence of character Y in string X. </td><td> </td>
	</tr>
	<tr>
		<td> $strrchr(X,Y) </td><td> Finds last occurrence of character Y in string X. </td><td> </td>
	</tr>
	<tr>
		<td> $strstr(X,Y) </td><td> Finds first occurrence of string Y in string X. </td><td> </td>
	</tr>
	<tr>
		<td> $select(N,A,B,C,&hellip;.) </td><td> Returns N-th of A,B,C&hellip; parameters. </td><td> </td>
	</tr>
	<tr>
		<td> $repeat(X,N) </td><td> Repeats X N times. </td><td> </td>
	</tr>
	<tr>
		<td> $replace(A,B,C) </td><td> Replaces all occurrences of string B in string A with string C. </td><td> </td>
	</tr>
	<tr>
		<td> $ext(X) </td><td> Extracts extension from file path / file name. </td><td> $ext(%path%) </td>
	</tr>
	<tr>
		<td> $substr(A,B,C) </td><td> Returns substring of string A, starting from B-th character and ending at C-th character </td><td> $substr(blah,1,2) &rArr; “bl” </td>
	</tr>
	<tr>
		<td> $trim(A) </td><td> Trims leading/trailing space characters from A. </td><td> $trim(%title%) </td>
	</tr>
	<tr>
		<td> $tab() </td><td> Generates a tab character; equivalent to $char(9). See “tab character” explanation below for more info about its use. </td><td> $tab() </td>
	</tr>
	<tr>
		<td> $stripprefix(X) </td><td> Removes “A” and “The” prefixes from X. </td><td> $stripprefix(%artist%) &rArr; “The Prodigy” becomes “Prodigy” </td>
	</tr>
	<tr>
		<td> $stripprefix(X,prefix1,prefix2,&hellip;) </td><td> Removes the specified prefixes from X. </td><td> $stripprefix(%artist%,a,the) &rArr; “The Prodigy” becomes “Prodigy” </td>
	</tr>
	<tr>
		<td> $swapprefix(X) </td><td> Moves “A” and “The” prefixes to the end of X. </td><td> $swapprefix(%artist%) &rArr; “The Prodigy” becomes “Prodigy, The” </td>
	</tr>
	<tr>
		<td> $swapprefix(X,prefix1,prefix2,&hellip;) </td><td> Moves the specified prefixes to the end of X. </td><td> $swapprefix(%artist%,a,the) &rArr; “The Prodigy” becomes “Prodigy, The” </td>
	</tr>
	<tr>
		<td> $peak_to_db(X) </td><td>Converts audio peak value from 0..1 PCM to decibels. See also: %replaygain_track_peak_db%, %replaygain_album_peak_db%</td><td> $peak_to_db(%replaygain_track_peak%) &rArr; “0.5” becomes “-6.02 dB” </td>
	</tr>
</table>
<table class="inline">
	<tr>
		<td> $year(time) </td><td> Retrieves the year part (formatted as four digits) from a time/date string. </td><td> $year(%last_modified%) </td>
	</tr>
	<tr>
		<td> $month(time) </td><td> Retrieves the month part (formatted as two digits) from a time/date string. </td><td> $month(%last_modified%) </td>
	</tr>
	<tr>
		<td> $day_of_month(time) </td><td> Retrieves the day of month part (formatted as two digits) from a time/date string. </td><td> $day_of_month(%last_modified%) </td>
	</tr>
	<tr>
		<td> $date(time) </td><td> Retrieves the date part (formatted as <em>YYYY-MM-DD</em>) from a time/date string. </td><td> $date(%last_modified%) </td>
	</tr>
	<tr>
		<td> $time(time) </td><td> Retrieves the time part (formatted as <em>HH:MM:SS</em> or <em>HH:MM</em>) from a date/time string. </td><td> $time(%last_modified%) </td>
	</tr>
</table>

</div>
<!-- SECTION "Functions" [5919-11937] -->
<h3><a name="variable_operations" id="variable_operations">Variable operations</a></h3>
<div class="level3">
<ul>
<li class="level1"><div class="li"> Variables allow you to store intermediate results of text processing in order to reduce size of your formatting string.</div>
</li>
<li class="level1"><div class="li"> Variables are not kept between instances of title formatting process and modifying actual file info with them is not possible.</div>
</li>
<li class="level1"><div class="li"> Variables don&#039;t allow you to do anything that you couldn&#039;t do without them already. They only allow you to shorten certain overcomplicated scripts.</div>
</li>
</ul>
<table class="inline">
	<tr>
		<th> Syntax </th><th> Description </th><th> Example </th>
	</tr>
	<tr>
		<td> $put(name,text) </td><td> Sets the variable named <em>name</em> to <em>text</em> and returns <em>text</em>. </td><td> “$put(x,blah)” sets variable x to “blah” and returns “blah”. </td>
	</tr>
	<tr>
		<td> $puts(name,text) </td><td> Silent version of $put(). Same as $put(name,text), but returns an empty string. </td><td> </td>
	</tr>
	<tr>
		<td> $get(name) </td><td> Returns the value of the variable named <em>name</em> or an empty string if such variable hasn&#039;t been set. </td><td> “$puts(x,blah)$get(x)$get(x)” returns “blahblah” </td>
	</tr>
</table>

</div>
<!-- SECTION "Variable operations" [11938-12838] -->
<h3><a name="other" id="other">Other</a></h3>
<div class="level3">
<table class="inline">
	<tr>
		<th> Syntax </th><th> Description </th><th> Example </th>
	</tr>
	<tr>
		<td> [ &hellip;. ] </td><td> Discards contents of the bracket when no fields referenced inside are present. Commonly used to create parts of formatting scripts that are active only when relevant fields are found. </td><td> %artist% - [%album% / ]%title% </td>
	</tr>
	<tr>
		<td> &#039; (single quotation mark) </td><td> Inserts specified text bypassing syntax processing; allows special characters such as %,$,[,] to be inserted. In order to insert a quotation mark character, use &#039;&#039; (two single quotation marks). </td><td> </td>
	</tr>
	<tr>
		<td> // </td><td> Comments, can be placed only at the beginning of a new line; prevent any characters following them until the end of line from being parsed. </td><td> </td>
	</tr>
	<tr>
		<td> End-of-line characters </td><td> Ignored; you can make your script more readable by splitting it into multiple lines, without affecting its output. </td><td> </td>
	</tr>
	<tr>
		<td> Tab character </td><td> Used to control text alignment in certain contexts such as status bar. See also: $tab(). </td><td> %title%$tab()%length% </td>
	</tr>
	<tr>
		<td> Color control: &lt; &gt; </td><td> Used to dim or highlight text, currently available in playlist and status bar. There are 3 dim and 3 highlight levels, accessible by repeating color control characters. </td><td> &lt;dim&gt; &gt;highlight&lt; &gt;&gt;extrahighlight&lt;&lt; </td>
	</tr>
</table>

</div>
<!-- SECTION "Other" [12839-] --></div>
</body>
</html>
